package example.simple_mindmap.common.designs.chain;

import java.util.LinkedList;

/**
 * @Program: 8.mindmap
 * @Author: 海里的鱼
 * @Create: 2024-09-08 19:41
 * @Name: 责任链处理者列表
 * @Desc: TODO
 */
public class ChainList {

    private LinkedList<ChainNode> chainNodes = new LinkedList<>();

    public <T extends IChainHandlerStrategy> ChainList add(Class<T> handler,String handlerName){
        chainNodes.add(new ChainNode<T>(handler,null,handlerName));
        return this;
    }

    public <T extends IChainHandlerStrategy> ChainList add(T handler,String handlerName){
        chainNodes.add(new ChainNode<T>(null,handler,handlerName));
        return this;
    }

    public LinkedList<ChainNode> getChainNodes() {
        return chainNodes;
    }

    public void setChainNodes(LinkedList<ChainNode> chainNodes) {
        this.chainNodes = chainNodes;
    }
}
